package com.powernobug.util;

import com.powernobug.bean.vo.BaseRespVo;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @Author: 肖云戈
 * @CreateTime: 2024-08-16
 * @Description:
 */
public class DispatchUtil {
    private DispatchUtil() {}

    public static BaseRespVo taskDispatcher(String operator, HttpServletRequest req, HttpServlet instance) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
        Method method = instance.getClass().getDeclaredMethod(operator, HttpServletRequest.class);
        method.setAccessible(true);
        return (BaseRespVo) method.invoke(instance, req);
    }
}
